/*
 * PauseScreen.java
 *
 * Created on April 30, 2007, 10:10 PM
 *
 * Copyright (c) 2007 Daniel Gronau
 *
 * This file is part of KanjiTori.
 *
 * KanjiTori is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * KanjiTori is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */

package kanjitori.graphics.ortho.status;

import com.jme.scene.Node;
import com.jme.scene.shape.Quad;
import com.jme.system.DisplaySystem;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.util.ResourceBundle;
import kanjitori.graphics.ortho.Ortho;
import kanjitori.util.Cache;

/**
 *
 * @author DGronau
 */
public class PauseScreen extends Ortho {
    
    private final static Font FONT = Cache.getFont("Arial Unicode MS", Font.PLAIN, 25);
    
    private ResourceBundle bundle = ResourceBundle.getBundle("kanjitori/resources/String");
    private Quad pausedQuad;
    
    /** Creates a new instance of PauseScreen */
    public PauseScreen() {
        node = new Node("pause");
       
        int width = DisplaySystem.getDisplaySystem().getWidth();
        int height = DisplaySystem.getDisplaySystem().getHeight();
        
        Rectangle pausedPos = new Rectangle(width/2 - 200, height/2 + 100, 400, 200);
        node.attachChild(pausedQuad = getQuad("paused", pausedPos));
        initPaused();

    }
    
    private void initPaused() {
        
        BufferedImage bi = new BufferedImage(400, 200, BufferedImage.TYPE_INT_ARGB);
        Graphics2D bg = (Graphics2D) bi.getGraphics();
        bg.setFont(FONT);
        String pausedString = bundle.getString("PauseState");
        String resumeString = bundle.getString("PauseKeyResume");
        String quitString = bundle.getString("PauseKeyQuit");

        int widthPaused = bg.getFontMetrics().stringWidth(pausedString);
        int widthResumed = bg.getFontMetrics().stringWidth(resumeString);
        int widthQuit = bg.getFontMetrics().stringWidth(quitString);
        int widthKeys = Math.max(widthResumed, widthQuit);
        
        bg.setColor(new Color(80,50,50,130));
        bg.fillRoundRect(200 - 22 - widthPaused /2, 1, widthPaused + 44, 30, 5, 5);
        bg.setColor(new Color(50,50,80,130));
        bg.fillRoundRect(200 - 22 - widthKeys /2, 200 - 71 , widthKeys + 44, 70, 5, 5);
        
        bg.setColor(Color.BLACK);
        bg.setStroke(new BasicStroke(2));
        bg.drawRoundRect(200 - 22 - widthPaused /2, 1, widthPaused + 44, 30, 5, 5);
        bg.drawRoundRect(200 - 22 - widthKeys /2, 200 - 71 , widthKeys + 44, 70, 5, 5);
        
        bg.setColor(Color.ORANGE);
        bg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                            RenderingHints.VALUE_ANTIALIAS_ON);
        bg.drawString(pausedString, 200 - widthPaused /2, 24);
        bg.drawString(resumeString, 200 - widthResumed /2, 200 - 70 + 24);
        bg.drawString(quitString, 200 - widthQuit /2, 200 - 35 + 24);
        
        bg.dispose();
        
        setBufferedImage(bi, pausedQuad);
    }    
   
 
}
